package com.easywan.pojo;

import java.util.List;
import java.util.Map;

import com.easywan.vo.BaseManagerMenueRes;

public class IResultSupport {
	
	public static <T> IResult buildResult(int code,String message,List<T> model){
		return buildResult(code,message,null,model);
	}
	public static IResult buildResult(Integer code, String message) {
		return buildResult(code,message,null,null);
	}
	public static <T> IResult buildResult(int code,String message,T model){
		return buildResult(code,message,model,null);
	}
	public static <T> IResult buildResult(Integer successCode, List<T> models) {
		return buildResult(successCode,"",null,models);
	}
	public static <T> IResult buildResult(Integer successCode,Object model, List<T> models) {
		return buildResult(successCode,null,model,models);
	}
	public static <T> IResult buildResult(Integer successCode,String msg,Object model, List<T> models) {
		return new Result<T>(successCode,msg,model,models);
	}
	
	@SuppressWarnings("unchecked")
	public static void setModel(IResult result,String model){
		((Result<String>)result).setModel(model);
	}
	public static IResult buildSuccessResult(String msg) {
		
		return buildResult(IResult.SUCCESS_CODE,msg);
	}
	public static IResult buildFailtResult(String msg) {
		
		return buildResult(IResult.FAILT_CODE,msg);
	}
	public  static <T> IResult buildSuccessResult(List<T> gtds, PageRow pageRow) {
		Result result = (Result) buildResult(IResult.SUCCESS_CODE,null,null,gtds);
		result.setPage(pageRow);
		return result;
	}
}
